<template>
	<view>
			<!-- <el-search :value="searchText" @input="(data)=>{searchText=data}"></el-search> -->
				<el-search v-model="searchText"></el-search>
				<view v-for="item in searchList" :key="item.id">
					
					<HouseItem :item="item"></HouseItem>
				</view>
	</view>
</template>

<script>
	import ElSearch from '@/components/el-search/el-search.vue'
	import {searchHouse} from '@/api/home.js'
	import HouseItem from '@/components/house-item/house-item.vue'
	export default {
		data() {
			return {
				searchText:'',
				searchList:[]
			};
		},
		watch:{
			searchText(newVal){
				//发送axios请求
				if(newVal){
					this.search()
				}
				
			}
		},
		methods:{
			async search(){
				let data = {
					searchkey:this.searchText
				}
				let res =  await searchHouse(data)
				this.searchList = res.data.map(item=>{
					item.tabs =JSON.parse( item.tabs.replace(/'/g,'"'));
					return item;
				})
				
				
				
				console.log(res);
			}
		},
			
		components:{
			ElSearch,
			HouseItem
		}
	}
</script>

<style lang="scss">

</style>
